//#define __DEBUG__
// by Xeno
#define THIS_FILE "fn_takewfwp.sqf"
#include "x_setup.sqf"

private ["_ggrp","_gtarget_pos","_gwp"];
PARAMS_2(_ggrp,_gtarget_pos);
_ggrp = _ggrp call FUNC(getgroup);
__TRACE_2("TakeWFWP",_ggrp,_gtarget_pos)
_ggrp setbehaviour "AWARE";
_gwp = _ggrp addWaypoint [_gtarget_pos, 0];
_gwp setwaypointtype "MOVE";
_gwp setWaypointCombatMode "YELLOW";
_gwp setWaypointSpeed "NORMAL";
_gwp setWaypointTimeout [60, 60 + random 20, 80 + random 20];
_gwp setWaypointStatements ["TRUE", "call {private '_xxgrp';_xxgrp = this call d_fnc_getgroup; _xxgrp setVariable ['d_takingwf', false];if ((_xxgrp call d_fnc_GetAliveUnitsGrp) > 0) then {[_xxgrp] call d_fnc_checknextwf}}"];
_ggrp setVariable [QGVAR(takingwf), true];